<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.awk</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (AWK) - Theme (Breeze Dark)"/>
</head><body style="background-color:#232629;color:#cfcfc2"><pre>
<span style="color:#7a7c7d;">#!/usr</span>
<span style="color:#7a7c7d;"># AWK hl test</span>

<span style="color:#7a7c7d;"># </span><span style="color:#2980b9;background-color:#153042;">BEGIN</span><span style="color:#7a7c7d;"> and </span><span style="color:#2980b9;background-color:#153042;">END</span><span style="color:#7a7c7d;"> are also matched as patterns</span>
<span style="color:#fdbc4b;">BEGIN</span> {
	p = <span style="color:#f67400;">0</span>;
}

<span style="color:#27ae60;">/</span><span style="color:#da4453;">some pattern</span><span style="color:#27ae60;">/</span> {
	p++;
}

<span style="color:#7a7c7d;"># / inside brackets is not considered end of expression</span>
<span style="color:#7a7c7d;"># a loose division operator (/) is not mismatched as a pattern.</span>
<span style="color:#2980b9;">$1</span> =~ <span style="color:#27ae60;">/[^</span><span style="color:#da4453;">abc/</span><span style="color:#27ae60;">]</span><span style="color:#da4453;">def</span><span style="color:#27ae60;">/</span> || b == <span style="color:#f67400;">3</span> / <span style="color:#f67400;">5</span> {

	<span style="color:#8e44ad;">gsub</span> ( <span style="color:#7f8c8d;">FILENAME</span> );

}

<span style="color:#7a7c7d;"># </span><span style="color:#ca9219;background-color:#451e1a;font-weight:bold;">TODO</span><span style="color:#7a7c7d;"> and </span><span style="color:#ca9219;background-color:#451e1a;font-weight:bold;">FIXME</span><span style="color:#7a7c7d;"> also work in comments in Awk.</span>

<span style="color:#7a7c7d;"># Also backslash in patterns works.</span>
<span style="color:#27ae60;">/\</span><span style="color:#3daee9;">/</span><span style="color:#da4453;">usr</span><span style="color:#27ae60;">\</span><span style="color:#3daee9;">/</span><span style="color:#da4453;">bin</span><span style="color:#27ae60;">\</span><span style="color:#3daee9;">/</span><span style="color:#da4453;">awk</span><span style="color:#27ae60;">/</span> { <span style="font-weight:bold;">print</span> <span style="color:#f44f4f;">&quot;This is me&quot;</span>; }

<span style="color:#fdbc4b;">END</span> {
	<span style="font-weight:bold;">print</span> p;
}

<span style="font-weight:bold;">function</span> myfunc()
{
    <span style="font-weight:bold;">print</span> <span style="color:#f67400;">42</span>
}

<span style="color:#27ae60;">/</span><span style="color:#da4453;">abc</span><span style="color:#27ae60;">/</span>,<span style="color:#27ae60;">/</span><span style="color:#da4453;">a</span><span style="color:#27ae60;">[</span><span style="color:#da4453;">b</span><span style="color:#27ae60;">]</span><span style="color:#da4453;">c</span><span style="color:#27ae60;">/</span>{
	<span style="color:#7a7c7d;"># parameter with a regex</span>
	<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#8e44ad;">match</span>(<span style="color:#2980b9;">$0</span>, <span style="color:#27ae60;">/</span><span style="color:#da4453;">a</span><span style="color:#27ae60;">/</span>)) {}

	<span style="color:#f44f4f;">&quot;x</span><span style="color:#3daee9;">\a</span><span style="color:#f44f4f;">x</span><span style="color:#3daee9;">\n</span><span style="color:#f44f4f;">x</span><span style="color:#3daee9;">\</span><span style="color:#da4453;text-decoration:underline;">e</span><span style="color:#f44f4f;">x</span><span style="color:#3daee9;">\</span><span style="color:#da4453;text-decoration:underline;">z</span><span style="color:#f44f4f;">x</span><span style="color:#3daee9;">\023</span><span style="color:#f44f4f;">x</span><span style="color:#3daee9;">\2</span><span style="color:#f44f4f;">x</span><span style="color:#3daee9;">\xff</span><span style="color:#f44f4f;">x</span><span style="color:#3daee9;">\xFf\xa</span><span style="color:#f44f4f;">x</span><span style="color:#3daee9;">\12</span><span style="color:#f44f4f;">x&quot;</span>

	a =~ <span style="color:#27ae60;">/[</span><span style="color:#0099ff;font-weight:bold;">[:alpha:]</span><span style="color:#27ae60;">]/</span>
	a =~ <span style="color:#27ae60;">/[</span><span style="color:#da4453;">xx</span><span style="color:#0099ff;font-weight:bold;">[:alpha:]</span><span style="color:#da4453;">xx</span><span style="color:#27ae60;">]/</span>
	a =~ <span style="color:#27ae60;">/[</span><span style="color:#da4453;">a</span><span style="color:#27ae60;">-</span><span style="color:#da4453;">z</span><span style="color:#0099ff;font-weight:bold;">[:alpha:]</span><span style="color:#da4453;">xx-</span><span style="color:#27ae60;">]/</span>
	a =~ <span style="color:#27ae60;">/[</span><span style="color:#da4453;">]a</span><span style="color:#27ae60;">]/</span>
	a =~ <span style="color:#27ae60;">/[</span><span style="color:#da4453;">-a</span><span style="color:#27ae60;">]/</span>
	a =~ <span style="color:#27ae60;">/[^</span><span style="color:#da4453;">]a</span><span style="color:#27ae60;">]/</span>
	a =~ <span style="color:#27ae60;">/[^</span><span style="color:#da4453;">-a</span><span style="color:#27ae60;">]/</span>
	a =~ <span style="color:#27ae60;">/[</span><span style="color:#da4453;">a</span><span style="color:#27ae60;">]</span><span style="color:#da4453;">a</span><span style="color:#27ae60;">\</span><span style="color:#3daee9;">/</span><span style="color:#27ae60;">\</span><span style="color:#3daee9;">n</span><span style="color:#27ae60;">/</span>
	<span style="color:#7a7c7d;"># incomplete regex</span>
	a =~ <span style="color:#27ae60;">/[</span><span style="color:#da4453;">xx</span><span style="color:#0099ff;font-weight:bold;">[:</span><span style="color:#27ae60;">alph</span>
	a = <span style="color:#f67400;">23.2</span>
}
</pre></body></html>
